#include <interface.h>
#include <iostream>

DECLARE_DRAWABLE_BEGIN(Test, "Test/arc", 0,2,1)
  virtual void init() override {
    shader_.loadPath("arc.vs", "arc.fs", "arc.gs");

    float vertices[] = {
      // positions       slides     colors
      -0.45f,  0.45f,    8.0f,      1.0f, 0.0f, 0.0f,
       0.45f,  0.45f,    16.0f,     0.0f, 1.0f, 0.0f,
       0.45f, -0.45f,    100.0f,     0.0f, 0.0f, 1.0f,
      -0.45f, -0.45f,    1000.0f,     1.0f, 0.0f, 1.0f,
    };

    glGenVertexArrays(1, &VAO_);
    glGenBuffers(1, &VBO_);
    glBindVertexArray(VAO_);

    glBindBuffer(GL_ARRAY_BUFFER, VBO_);
    glBufferData(GL_ARRAY_BUFFER, sizeof(vertices), vertices, GL_STATIC_DRAW);

    // position attribute
    glVertexAttribPointer(0, 4, GL_FLOAT, GL_FALSE, 6 * sizeof(float), (void*)0);
    glEnableVertexAttribArray(0);

    // color attribute
    glVertexAttribPointer(1, 4, GL_FLOAT, GL_FALSE, 6 * sizeof(float), (void*)(3 * sizeof(float)));
    glEnableVertexAttribArray(1);

    glBindVertexArray(0);
  }
  virtual void uninit() override {
    glDeleteVertexArrays(1, &VAO_);
    glDeleteBuffers(1, &VBO_);
    shader_.free();
  }
  virtual void render() override {
    shader_.use();
    glBindVertexArray(VAO_);
    glDrawArrays(GL_POINTS, 0, 4);
  }
 protected:
  GLuint shaderProgram_;
  GLuint VAO_, VBO_;
  Shader shader_;
DECLARE_DRAWABLE_END(Test)